package com.ruoyi.system.outto.game.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.model.domain.AccountInfo;
import com.ruoyi.system.model.domain.InfoImg;
import com.ruoyi.system.model.domain.SalePartner;
import com.ruoyi.system.model.mapper.AccountInfoMapper;
import com.ruoyi.system.model.mapper.InfoImgMapper;
import com.ruoyi.system.outto.core.LCConstant;
import com.ruoyi.system.outto.core.OutUrlConstant;
import com.ruoyi.system.outto.core.constant.GameTypeConstant;
import com.ruoyi.system.outto.game.CRAPI;
import com.ruoyi.system.outto.game.CommonApi;
import com.ruoyi.system.outto.game.LXYAPI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.omg.CORBA.OBJ_ADAPTER;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.jws.Oneway;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author lz
 * @version 1.0
 * @date 2022/8/16 22:58
 */
@Slf4j
@Service
public class LYXApiImpl implements LXYAPI {

    @Value("${desc.title}")
    private String descTitle;

    @Resource
    private InfoImgMapper infoImgMapper;
    @Resource
    private AccountInfoMapper accountInfoMapper;

    @Override
    public AjaxResult addGame(AccountInfo accountInfo, Long userId,SalePartner sa) {



        if (Objects.equals("原神",accountInfo.getType())){
            if (!Objects.equals("邮箱可换绑",accountInfo.getLevel())){
                throw new GlobalException("乐逍遥原神只卖可换绑的");
            }
        }

        Map<String, Object> resultMap = new HashMap<>();
        String url = sa.getThreeOther();
        Map<String, Object> params = params(accountInfo, userId);
        params.put("level","2");
        params.put("username", sa.getSaleKey());
        String requestp = JSONObject.toJSONString(params);
        log.info("乐逍遥添加接口请求参数={}", requestp);
        String type = accountInfo.getType();
        String result = null;
        if (type.equals(GameTypeConstant.WZRY)) {
            result = HttpUtils.sendPost(url + "?action=upload_item", requestp, "application/json");
        } else if (type.equals(GameTypeConstant.HPJY)) {
            result = HttpUtils.sendPost(url + "?action=upload_item_heping", requestp, "application/json");
        } else if (type.equals(GameTypeConstant.YS)) {
            List<Map<String,Object>> paramsList = new ArrayList<>();
            params.put("price", String.valueOf(accountInfo.getPrice()));
            paramsList.add(params);
            requestp = JSONObject.toJSONString(paramsList);
            log.info("乐逍遥添加接口请求参数={}", requestp);
            result = HttpUtils.sendPost("http://ys.bumihu.cn/ajax.php" + "?action=synchronous", requestp, "application/json");

            try{
                JSONArray objects = JSONArray.parseArray(result);
                if (!CollectionUtils.isEmpty(objects)){
                    Object o = objects.get(0);
                    JSONObject resultJson = JSONObject.parseObject(o.toString());
                    if (!"200".equals(resultJson.getString("status"))) {
                        resultMap.put("code", 500);
                    } else {
                        resultMap.put("code", 200);
                    }
                    resultMap.put("req", requestp);
                    resultMap.put("res", result);
                    resultMap.put("msg", resultJson.toJSONString());
                    return AjaxResult.success(resultMap);
                }
            }catch (Exception e){
                JSONObject resultJson = JSONObject.parseObject(result);
                if (!"200".equals(resultJson.getString("status"))) {
                    resultMap.put("code", 500);
                } else {
                    resultMap.put("code", 200);
                }
                resultMap.put("req", requestp);
                resultMap.put("res", result);
                resultMap.put("msg", resultJson.toJSONString());
                return AjaxResult.success(resultMap);
            }
        }
        log.info("乐逍遥添加接口返回参数={}", result);

        JSONObject resultJson = JSONObject.parseObject(result);
        if (!"200".equals(resultJson.getString("status"))) {
            resultMap.put("code", 500);
        } else {
            resultMap.put("code", 200);
        }
        resultMap.put("req", requestp);
        resultMap.put("res", result);
        resultMap.put("msg", resultJson.toJSONString());

        return AjaxResult.success(resultMap);
    }

    @Override
    public AjaxResult editGame(AccountInfo accountInfo, Long userId,SalePartner sa) {
        Map<String, Object> resultMap = new HashMap<>();
        String url = sa.getThreeOther();
        Map<String, Object> params = params(accountInfo, userId);
        params.put("username", sa.getSaleKey());
        String type = accountInfo.getType();
        String requestp = JSONObject.toJSONString(params);
        log.info("乐逍遥编辑接口请求参数={}", requestp);
        String result = null;
        if (type.equals(GameTypeConstant.WZRY)) {
            result = HttpUtils.sendPost(url + "?action=upload_item_edit&username=" + sa.getSaleKey() + "&tianxai_id=" + accountInfo.getId(), requestp, "application/json");
        } else if (type.equals(GameTypeConstant.HPJY)) {
            result = HttpUtils.sendPost(url + "?action=upload_item_heping_edit&username=" + sa.getSaleKey() + "&game_id=" + accountInfo.getId(), requestp, "application/json");
        } else if (type.equals(GameTypeConstant.YS)) {
            List<Map<String,Object>> paramsList = new ArrayList<>();
            params.put("price", String.valueOf(accountInfo.getPrice()));
            paramsList.add(params);
            requestp = JSONObject.toJSONString(paramsList);
            log.info("乐逍遥原神编辑编辑接口请求参数={}", requestp);
            result = HttpUtils.sendPost("http://ys.bumihu.cn/ajax.php" + "?action=synchronous_edit&username=" + sa.getSaleKey() + "&product_id=" + accountInfo.getId(), requestp, "application/json");

            try{
                JSONArray objects = JSONArray.parseArray(result);
                if (!CollectionUtils.isEmpty(objects)){
                    Object o = objects.get(0);
                    JSONObject resultJson = JSONObject.parseObject(o.toString());
                    if (!"200".equals(resultJson.getString("status"))) {
                        resultMap.put("code", 500);
                    } else {
                        resultMap.put("code", 200);
                    }
                    resultMap.put("req", requestp);
                    resultMap.put("res", result);
                    resultMap.put("msg", resultJson.toJSONString());
                    return AjaxResult.success(resultMap);
                }
            }catch (Exception e){
                JSONObject resultJson = JSONObject.parseObject(result);
                if (!"200".equals(resultJson.getString("status"))) {
                    resultMap.put("code", 500);
                } else {
                    resultMap.put("code", 200);
                }
                resultMap.put("req", requestp);
                resultMap.put("res", result);
                resultMap.put("msg", resultJson.toJSONString());
                return AjaxResult.success(resultMap);
            }


        }
        log.info("乐逍遥编辑接口返回参数={}", result);


        JSONObject resultJson = JSONObject.parseObject(result);
        if (!"200".equals(resultJson.getString("status"))) {
            resultMap.put("code", 500);
        } else {
            resultMap.put("code", 200);
        }
        resultMap.put("req", requestp);
        resultMap.put("res", result);
        resultMap.put("msg", resultJson.toJSONString());
        return AjaxResult.success(resultMap);

    }

    @Override
    public AjaxResult delGame(Long id, Long userId,SalePartner sa) {
        Map<String, Object> resultMap = new HashMap<>();
        String url = sa.getThreeOther();
        Map<String, Object> params = new HashMap<>();
        AccountInfo accountInfo = accountInfoMapper.selectAccountInfoById(id);
        String requestp = JSONObject.toJSONString(params);
        String result = null;
        String type = accountInfo.getType();
        if (type.equals(GameTypeConstant.WZRY)) {
            params.put("tianxai_id", String.valueOf(id));
            log.info("乐逍遥删除接口请求参数={}", params);
            result = HttpUtils.doPostForm(url + "?action=delete_synchronous&type=delete&username=" + sa.getSaleKey(), params, null);
        } else if (type.equals(GameTypeConstant.HPJY)) {
            params.put("game_id", String.valueOf(id));
            log.info("乐逍遥删除接口请求参数={}", params);
            result = HttpUtils.doPostForm(url + "?action=delete_synchronous_heping&type=delete&username=" + sa.getSaleKey(), params, null);
        } else if (type.equals(GameTypeConstant.YS)) {
            params = params(accountInfo, userId);
            params.put("username", sa.getSaleKey());
            params.put("level", "1");
            params.put("product_id", String.valueOf(id));
            List<Map<String,Object>> paramsList = new ArrayList<>();
            paramsList.add(params);
            requestp = JSONObject.toJSONString(paramsList);
            log.info("乐逍遥删除接口请求参数={}", params);
            result = HttpUtils.sendPost("http://ys.bumihu.cn/ajax.php" + "?action=synchronous_edit&username=" + sa.getSaleKey() + "&product_id=" + accountInfo.getId(), requestp, "application/json");

            try{
                JSONArray objects = JSONArray.parseArray(result);
                if (!CollectionUtils.isEmpty(objects)){
                    Object o = objects.get(0);
                    JSONObject resultJson = JSONObject.parseObject(o.toString());
                    if (!"200".equals(resultJson.getString("status"))) {
                        resultMap.put("code", 500);
                    } else {
                        resultMap.put("code", 200);
                    }
                    resultMap.put("req", requestp);
                    resultMap.put("res", result);
                    resultMap.put("msg", resultJson.toJSONString());
                    return AjaxResult.success(resultMap);
                }
            }catch (Exception e){
                JSONObject resultJson = JSONObject.parseObject(result);
                if (!"200".equals(resultJson.getString("status"))) {
                    resultMap.put("code", 500);
                } else {
                    resultMap.put("code", 200);
                }
                resultMap.put("req", requestp);
                resultMap.put("res", result);
                resultMap.put("msg", resultJson.toJSONString());
                return AjaxResult.success(resultMap);
            }
        }
//        log.info("乐逍遥删除接口请求参数={}", requestp);
        log.info("乐逍遥删除接口返回参数={}", result);


        JSONArray objects = JSONObject.parseArray(result);
        if (!CollectionUtils.isEmpty(objects)) {
            Object o = objects.get(0);
            String s = JSONObject.toJSONString(o);
            JSONObject resultJson = JSONObject.parseObject(s);
            if (!"200".equals(resultJson.getString("status"))) {
                resultMap.put("code", 500);
            } else {
                resultMap.put("code", 200);
            }
            resultMap.put("req", requestp);
            resultMap.put("res", result);
            resultMap.put("msg", resultJson.toJSONString());
        }
        return AjaxResult.success(resultMap);
    }

    private Map<String, Object> params(AccountInfo accountInfo, Long userId) {

        Map<String, Object> params = new TreeMap<>();
        String gameType = accountInfo.getType();
        String title = accountInfo.getDes();
        String titleImg = accountInfo.getTitleImg();
        params.put("level", "2");
        params.put("title", "【" + descTitle + "_" + accountInfo.getId() + "】 " + title);
        BigDecimal price = accountInfo.getPrice();
        params.put("ztprice", String.valueOf(price));

        if (gameType.equals(GameTypeConstant.WZRY)) {
            params.put("tianxai_id", accountInfo.getId().toString());
        } else if (gameType.equals(GameTypeConstant.HPJY)) {
            params.put("game_id", accountInfo.getId().toString());
        }
        params.put("thumb", StringUtils.isEmpty(titleImg) ? "https://game.ikbh.top/logo/no_img.jpg" : titleImg);
        params.put("addtime", DateUtils.getTimeStempM());
        String s = regionalCover(accountInfo.getType(), accountInfo.getRegional());
        if (Objects.isNull(s)) {
            throw new GlobalException("区服匹配失败，当前游戏:" + gameType + "，区服" + accountInfo.getRegional());
        }
        params.put("catid", s);

        //图片
        StringBuilder imagesSb = new StringBuilder();
        InfoImg infoImg = new InfoImg();
        infoImg.setInfoId(accountInfo.getId());
        infoImg.setType(Constants.STR_1);
        List<InfoImg> infoImgs = infoImgMapper.selectInfoImgList(infoImg);
        if (CollectionUtils.isEmpty(infoImgs)) {
        } else {
            for (InfoImg img : infoImgs) {
                imagesSb.append("<p><img src=\"" + img.getImgUrl() + "\" /></p>");
            }
        }
        String imgStr = imagesSb.toString().replace("\\/","");
        params.put("content", StringUtils.isEmpty(imagesSb.toString()) ? accountInfo.getDes() + "<p><img src=\"https://game.ikbh.top/logo/no_img.jpg\"/></p >" : accountInfo.getDes() + imgStr);

        if (GameTypeConstant.WZRY.equals(gameType)) {
            params.put("duanwei", accountInfo.getLevel());
            params.put("mingwen", 3);
            Integer skins = accountInfo.getSkins();
            if (skins != null) {
                params.put("ztpf", skins);
                if (0 < skins && 51 > skins) {
                    params.put("shuliang", 1);
                }
                if (50 < skins && 101 > skins) {
                    params.put("shuliang", 2);
                }
                if (100 < skins && 189 > skins) {
                    params.put("shuliang", 3);
                }
                if (188 < skins && 301 > skins) {
                    params.put("shuliang", 4);
                }
                if (300 < skins) {
                    params.put("shuliang", 5);
                }
            }
            params.put("daqu", accountInfo.getRegional());

            if (1000 > price.intValue()) {
                params.put("price", 1);
            }
            if (1000 < price.intValue() && 2000 > price.intValue()) {
                params.put("price", 2);
            }
            if (2000 < price.intValue() && 3000 > price.intValue()) {
                params.put("price", 3);
            }
            if (3000 < price.intValue() && 5000 > price.intValue()) {
                params.put("price", 4);
            }
            if (5000 < price.intValue()) {
                params.put("price", 5);
            }

            StringBuffer neice = new StringBuffer("");
            if (title.contains("女武神")) {
                neice.append("2,");
            }
            if (title.contains("蔷薇恋人")) {
                neice.append("3,");
            }
            if (title.contains("优雅恋人")) {
                neice.append("4,");
            }
            if (title.contains("玩趣恶龙")) {
                neice.append("5,");
            }
            if (StringUtils.isNotEmpty(neice)) {
                params.put("neice", neice.toString());
            }


            StringBuffer rongyaoshuijing = new StringBuffer("");
            if (title.contains("全息碎影")) {
                rongyaoshuijing.append("1,");
            }
            if (title.contains("武则天")) {
                rongyaoshuijing.append("2,");
            }
            if (title.contains("倪克斯神谕")) {
                rongyaoshuijing.append("3,");
            }
            if (title.contains("星空梦想")) {
                rongyaoshuijing.append("4,");
            }
            if (title.contains("天鹅之梦")) {
                rongyaoshuijing.append("5,");
            }
            if (title.contains("杀手不太冷")) {
                rongyaoshuijing.append("6,");
            }
            if (title.contains("鸣剑")) {
                rongyaoshuijing.append("7,");
            }
            if (title.contains("无限飓风")) {
                rongyaoshuijing.append("8,");
            }
            if (title.contains("活力突击")) {
                rongyaoshuijing.append("9,");
            }
            if (title.contains("大秦")) {
                rongyaoshuijing.append("10,");
            }
            if (title.contains("星域神启")) {
                rongyaoshuijing.append("11,");
            }

            if (StringUtils.isNotEmpty(rongyaoshuijing)) {
                params.put("rongyaoshuijing", rongyaoshuijing.toString());
            }

            StringBuffer xingyuanpifu = new StringBuffer("");
            if (title.contains("幻海之心")) {
                xingyuanpifu.append("1,");
            }
            if (title.contains("金色仲夏夜")) {
                xingyuanpifu.append("2,");
            }
            if (title.contains("幽冥之眼")) {
                xingyuanpifu.append("3,");
            }
            if (title.contains("幽冥火")) {
                xingyuanpifu.append("4,");
            }
            if (title.contains("未来机甲")) {
                xingyuanpifu.append("5,");
            }
            if (title.contains("零号雷霆")) {
                xingyuanpifu.append("6,");
            }

            if (StringUtils.isNotEmpty(xingyuanpifu)) {
                params.put("xingyuanpifu", xingyuanpifu.toString());
            }
            StringBuffer xiyoupifu = new StringBuffer("");
            if (title.contains("凤求凰")) {
                xiyoupifu.append("1,");
            }
            if (title.contains("至尊宝")) {
                xiyoupifu.append("2,");
            }
            if (title.contains("梅西")) {
                xiyoupifu.append("3,");
            }
            if (title.contains("神威")) {
                xiyoupifu.append("4,");
            }
            if (title.contains("永曜之星")) {
                xiyoupifu.append("5,");
            }
            if (title.contains("天魔缭乱")) {
                xiyoupifu.append("6,");
            }
            if (title.contains("凤凰于飞")) {
                xiyoupifu.append("7,");
            }
            if (title.contains("大圣娶亲")) {
                xiyoupifu.append("8,");
            }
            if (title.contains("一生所爱")) {
                xiyoupifu.append("9,");
            }
            if (title.contains("白虎志")) {
                xiyoupifu.append("10,");
            }
            if (title.contains("玄武志")) {
                xiyoupifu.append("11,");
            }
            if (title.contains("麒麟志")) {
                xiyoupifu.append("12,");
            }
            if (title.contains("冰封战神")) {
                xiyoupifu.append("13,");
            }
            if (title.contains("魔法小厨娘")) {
                xiyoupifu.append("14,");
            }
            if (title.contains("武陵仙君")) {
                xiyoupifu.append("15,");
            }
            if (title.contains("青春决赛")) {
                xiyoupifu.append("16,");
            }
            if (title.contains("辉光之")) {
                xiyoupifu.append("17,");
            }
            if (title.contains("云端筑梦")) {
                xiyoupifu.append("18,");
            }
            if (title.contains("引擎之心")) {
                xiyoupifu.append("19,");
            }
            if (title.contains("密橘之夏")) {
                xiyoupifu.append("20,");
            }
            if (title.contains("热情桑巴")) {
                xiyoupifu.append("21,");
            }
            if (title.contains("神奇女侠")) {
                xiyoupifu.append("22,");
            }
            if (title.contains("蓝屏警告")) {
                xiyoupifu.append("23,");
            }
            if (title.contains("逐梦之星")) {
                xiyoupifu.append("24,");
            }
            if (title.contains("逐梦之影")) {
                xiyoupifu.append("25,");
            }
            if (title.contains("逐梦之翼")) {
                xiyoupifu.append("26,");
            }
            if (title.contains("逐梦之音")) {
                xiyoupifu.append("27,");
            }
            if (title.contains("纯白花嫁")) {
                xiyoupifu.append("28,");
            }
            if (title.contains("真爱至上")) {
                xiyoupifu.append("29,");
            }
            if (title.contains("霸王别姬")) {
                xiyoupifu.append("30,");
            }
            if (title.contains("霸王别姬")) {
                xiyoupifu.append("31,");
            }
            if (title.contains("时之彼端")) {
                xiyoupifu.append("32,");
            }
            if (title.contains("狮心王")) {
                xiyoupifu.append("33,");
            }
            if (title.contains("原初追逐")) {
                xiyoupifu.append("34,");
            }
            if (title.contains("美猴王")) {
                xiyoupifu.append("35,");
            }
            if (title.contains("冰冠公主")) {
                xiyoupifu.append("36,");
            }
            if (title.contains("梦之光")) {
                xiyoupifu.append("37,");
            }
            if (title.contains("嘻哈天王")) {
                xiyoupifu.append("38,");
            }
            if (title.contains("奇迹圣诞")) {
                xiyoupifu.append("39,");
            }
            if (title.contains("太华")) {
                xiyoupifu.append("40,");
            }
            if (title.contains("飞衡")) {
                xiyoupifu.append("41,");
            }
            if (title.contains("岱宗")) {
                xiyoupifu.append("42,");
            }
            if (title.contains("武圣")) {
                xiyoupifu.append("43,");
            }
            if (title.contains("龙胆")) {
                xiyoupifu.append("44,");
            }
            if (title.contains("虎魄")) {
                xiyoupifu.append("46,");
            }
            if (title.contains("裂魂")) {
                xiyoupifu.append("47,");
            }
            if (title.contains("朱雀")) {
                xiyoupifu.append("48,");
            }
            if (title.contains("青龙")) {
                xiyoupifu.append("49,");
            }
            if (title.contains("遇见飞天")) {
                xiyoupifu.append("50,");
            }
            if (title.contains("东方不败")) {
                xiyoupifu.append("51,");
            }
            if (title.contains("死亡摇滚")) {
                xiyoupifu.append("52,");
            }
            if (title.contains("华丽摇滚")) {
                xiyoupifu.append("53,");
            }
            if (title.contains("幽恒")) {
                xiyoupifu.append("54,");
            }
            if (title.contains("玄嵩")) {
                xiyoupifu.append("55,");
            }
            if (title.contains("如梦令")) {
                xiyoupifu.append("56,");
            }
            if (title.contains("嫦娥如梦令")) {
                xiyoupifu.append("57,");
            }
            if (title.contains("零号赤焰")) {
                xiyoupifu.append("58,");
            }
            if (title.contains("白晶晶")) {
                xiyoupifu.append("59,");
            }
            if (title.contains("祈雪")) {
                xiyoupifu.append("60,");
            }
            if (title.contains("时雨")) {
                xiyoupifu.append("61,");
            }
            if (title.contains("奔雷")) {
                xiyoupifu.append("62,");
            }
            if (title.contains("御风骁将")) {
                xiyoupifu.append("63,");
            }
            if (title.contains("战甲")) {
                xiyoupifu.append("64,");
            }
            if (title.contains("交锋男")) {
                xiyoupifu.append("65,");
            }
            if (title.contains("交锋女")) {
                xiyoupifu.append("66,");
            }
            if (title.contains("天狼狩猎者")) {
                xiyoupifu.append("67,");
            }
            if (title.contains("天狼绘梦者")) {
                xiyoupifu.append("68,");
            }
            if (title.contains("天狼征服者")) {
                xiyoupifu.append("69,");
            }
            if (title.contains("李逍遥")) {
                xiyoupifu.append("70,");
            }
            if (title.contains("异界灵")) {
                xiyoupifu.append("71,");
            }
            if (title.contains("冰霜恋舞曲")) {
                xiyoupifu.append("73,");
            }
            if (title.contains("天狼运算者")) {
                xiyoupifu.append("74,");
            }
            if (title.contains("孙行者")) {
                xiyoupifu.append("75,");
            }
            if (title.contains("猪悟能")) {
                xiyoupifu.append("76,");
            }
            if (title.contains("乒乓小将")) {
                xiyoupifu.append("77,");
            }
            if (title.contains("狂想玩偶猫")) {
                xiyoupifu.append("78,");
            }
            if (title.contains("云间")) {
                xiyoupifu.append("79,");
            }
            if (title.contains("真爱魔法")) {
                xiyoupifu.append("80,");
            }
            if (title.contains("傲雪")) {
                xiyoupifu.append("81,");
            }
            if (title.contains("女儿国国王")) {
                xiyoupifu.append("82,");
            }
            if (title.contains("匿光")) {
                xiyoupifu.append("83,");
            }
            if (title.contains("拒霜思")) {
                xiyoupifu.append("84,");
            } if (title.contains("寅虎心曲")) {
                xiyoupifu.append("85,");
            }if (title.contains("寅虎赤")) {
                xiyoupifu.append("86,");
            }
            if (title.contains("寅虎瑞焰")) {
                xiyoupifu.append("87,");
            }
            if (title.contains("寅虎展翼")) {
                xiyoupifu.append("88,");
            }
            if (title.contains("寅虎御盾")) {
                xiyoupifu.append("89,");
            }
            if (title.contains("时之祈愿")) {
                xiyoupifu.append("90,");
            }


            if (StringUtils.isNotEmpty(xiyoupifu)) {
                params.put("xiyoupifu", xiyoupifu.toString());
            }
            StringBuffer shishichuanshuo = new StringBuffer("");
            if (title.contains("启明星使")) {
                shishichuanshuo.append("1,");
            }
            if (title.contains("海洋之心")) {
                shishichuanshuo.append("2,");
            }
            if (title.contains("电玩小子")) {
                shishichuanshuo.append("3,");
            }
            if (title.contains("地狱之眼")) {
                shishichuanshuo.append("4,");
            }
            if (title.contains("地狱火")) {
                shishichuanshuo.append("5,");
            }
            if (title.contains("猫狗日记男")) {
                shishichuanshuo.append("6,");
            }
            if (title.contains("猫狗日记女")) {
                shishichuanshuo.append("7,");
            }
            if (title.contains("暗夜猫娘")) {
                shishichuanshuo.append("8,");
            }
            if (title.contains("久胜战神")) {
                shishichuanshuo.append("9,");
            }
            if (title.contains("一念神魔")) {
                shishichuanshuo.append("10,");
            }
            if (title.contains("千年之狐")) {
                shishichuanshuo.append("11,");
            }
            if (title.contains("圣诞老人")) {
                shishichuanshuo.append("12,");
            }
            if (title.contains("苍穹之光")) {
                shishichuanshuo.append("13,");
            }
            if (title.contains("蓝屏警告")) {
                shishichuanshuo.append("14,");
            }
            if (title.contains("水晶猎龙者")) {
                shishichuanshuo.append("15,");
            }
            if (title.contains("云霓雀翎")) {
                shishichuanshuo.append("16,");
            }
            if (title.contains("幽灵船长")) {
                shishichuanshuo.append("17,");
            }
            if (title.contains("胖达荣荣")) {
                shishichuanshuo.append("18,");
            }

            if (title.contains("仲夏夜之梦")) {
                shishichuanshuo.append("20,");
            }
            if (title.contains("末日机甲女")) {
                shishichuanshuo.append("21,");
            }
            if (title.contains("末日机甲男")) {
                shishichuanshuo.append("22,");
            }
            if (title.contains("白龙吟")) {
                shishichuanshuo.append("23,");
            }
            if (title.contains("超时空战士")) {
                shishichuanshuo.append("24,");
            }
            if (title.contains("街头霸王")) {
                shishichuanshuo.append("25,");
            }
            if (title.contains("冠军飞将")) {
                shishichuanshuo.append("26,");
            }
            if (title.contains("黑猫爱糖果")) {
                shishichuanshuo.append("27,");
            }
            if (title.contains("拳王")) {
                shishichuanshuo.append("28,");
            }
            if (title.contains("猫影幻舞")) {
                shishichuanshuo.append("29,");
            }
            if (title.contains("云鹰飞将")) {
                shishichuanshuo.append("30,");
            }
            if (title.contains("黄金白羊座")) {
                shishichuanshuo.append("31,");
            }
            if (title.contains("黄金射手座")) {
                shishichuanshuo.append("32,");
            }
            if (title.contains("黄金狮子座")) {
                shishichuanshuo.append("33,");
            }
            if (title.contains("绅士熊猫")) {
                shishichuanshuo.append("34,");
            }
            if (title.contains("神迹守卫")) {
                shishichuanshuo.append("35,");
            }
            if (title.contains("王者之锤")) {
                shishichuanshuo.append("36,");
            }
            if (title.contains("游园惊梦")) {
                shishichuanshuo.append("37,");
            }
            if (title.contains("驯魔猎人")) {
                shishichuanshuo.append("38,");
            }
            if (title.contains("猎兽之王")) {
                shishichuanshuo.append("39,");
            }
            if (title.contains("死神来了")) {
                shishichuanshuo.append("40,");
            }
            if (title.contains("迷踪丽影")) {
                shishichuanshuo.append("41,");
            }
            if (title.contains("仙境爱丽丝")) {
                shishichuanshuo.append("42,");
            }
            if (title.contains("夺宝奇兵")) {
                shishichuanshuo.append("43,");
            }
            if (title.contains("天堂奇兵")) {
                shishichuanshuo.append("44,");
            }
            if (title.contains("火炮千金")) {
                shishichuanshuo.append("46,");
            }
            if (title.contains("摇滚巨星")) {
                shishichuanshuo.append("46,");
            }
            if (title.contains("龙骑士")) {
                shishichuanshuo.append("47,");
            }
            if (title.contains("狮舞东方")) {
                shishichuanshuo.append("48,");
            }
            if (title.contains("黑桃队长")) {
                shishichuanshuo.append("49,");
            }
            if (title.contains("华丽摇滚")) {
                shishichuanshuo.append("50,");
            }
            if (title.contains("银河之约")) {
                shishichuanshuo.append("51,");
            }
            if (title.contains("星空之诺")) {
                shishichuanshuo.append("52,");
            }
            if (title.contains("乱世虎臣")) {
                shishichuanshuo.append("54,");
            }
            if (title.contains("青蛇")) {
                shishichuanshuo.append("55,");
            }
            if (title.contains("白蛇")) {
                shishichuanshuo.append("56,");
            }
            if (title.contains("赤莲之焰")) {
                shishichuanshuo.append("58,");
            }
            if (title.contains("遇见神鹿")) {
                shishichuanshuo.append("59,");
            }

            if (title.contains("李小龙")) {
                shishichuanshuo.append("60,");
            }
            if (title.contains("梁祝")) {
                shishichuanshuo.append("61,");
            }
            if (title.contains("时之恋人男")) {
                shishichuanshuo.append("62,");
            }
            if (title.contains("时之恋人女")) {
                shishichuanshuo.append("63,");
            }
            if (title.contains("音你心动男")) {
                shishichuanshuo.append("64,");
            }
            if (title.contains("音你心动女")) {
                shishichuanshuo.append("65,");
            }
            if (title.contains("遇见胡旋")) {
                shishichuanshuo.append("66,");
            }
            if (title.contains("淬星耀世")) {
                shishichuanshuo.append("67,");
            }
            if (title.contains("游龙清影")) {
                shishichuanshuo.append("68,");
            }
            if (title.contains("乞巧织情")) {
                shishichuanshuo.append("69,");
            }
            if (title.contains("航海奇遇记")) {
                shishichuanshuo.append("70,");
            }
            if (title.contains("飞鸢探春")) {
                shishichuanshuo.append("71,");
            }
            if (title.contains("心灵战警")) {
                shishichuanshuo.append("71,");
            }
            if (title.contains("心灵骇客")) {
                shishichuanshuo.append("73,");
            }
            if (title.contains("圣诞恋歌")) {
                shishichuanshuo.append("74,");
            }
            if (title.contains("圣诞狂欢")) {
                shishichuanshuo.append("75,");
            }
            if (title.contains("功夫厨神")) {
                shishichuanshuo.append("76,");
            }
            if (title.contains("节奏热浪")) {
                shishichuanshuo.append("77,");
            }

            if (StringUtils.isNotEmpty(shishichuanshuo)) {
                params.put("shishichuanshuo", shishichuanshuo.toString());
            }

            params.put("dengji",30);

        }
        if (GameTypeConstant.HPJY.equals(gameType)) {
            params.put("qiangxiep", accountInfo.getGuns());

            params.put("taozhuangp", accountInfo.getSuit());

            if (1000 > price.intValue()) {
                params.put("jiagep", 1);
            }
            if (1000 < price.intValue() && 2000 > price.intValue()) {
                params.put("jiagep", 2);
            }
            if (2000 < price.intValue() && 3000 > price.intValue()) {
                params.put("jiagep", 3);
            }
            if (3000 < price.intValue() && 5000 > price.intValue()) {
                params.put("jiagep", 4);
            }
            if (5000 < price.intValue() && 10000 > price.intValue()) {
                params.put("jiagep", 5);
            }
            if (10000 < price.intValue()) {
                params.put("jiagep", 6);
            }
        }
        if (GameTypeConstant.YS.equals(gameType)) {
            params.put("num", accountInfo.getHeroes());

            params.put("wuxing", accountInfo.getSkins());

            StringBuffer wuxingarr = new StringBuffer();

            if (title.contains("魈")) {
                wuxingarr.append("1,");
            }
            if (title.contains("刻晴")) {
                wuxingarr.append("2,");
            }
            if (title.contains("阿贝多")) {
                wuxingarr.append("3,");
            }
            if (title.contains("甘雨")) {
                wuxingarr.append("4,");
            }
            if (title.contains("迪卢克")) {
                wuxingarr.append("5,");
            }
            if (title.contains("达达利亚")) {
                wuxingarr.append("6,");
            }
            if (title.contains("可莉")) {
                wuxingarr.append("7,");
            }
            if (title.contains("琴")) {
                wuxingarr.append("8,");
            }
            if (title.contains("莫娜")) {
                wuxingarr.append("9,");
            }
            if (title.contains("七七")) {
                wuxingarr.append("10,");
            }
            if (title.contains("温蒂")) {
                wuxingarr.append("11,");
            }
            if (title.contains("钟离")) {
                wuxingarr.append("12,");
            }
            if (title.contains("胡桃")) {
                wuxingarr.append("13,");
            }
            if (title.contains("优菈")) {
                wuxingarr.append("14,");
            }
            if (title.contains("枫原万叶")) {
                wuxingarr.append("15,");
            }
            if (title.contains("神里绫华")) {
                wuxingarr.append("16,");
            }
            if (title.contains("宵宫")) {
                wuxingarr.append("17,");
            }
            if (title.contains("雷电将军")) {
                wuxingarr.append("18,");
            }
            if (title.contains("珊瑚宫心海")) {
                wuxingarr.append("19,");
            }
            if (title.contains("埃洛伊")) {
                wuxingarr.append("20,");
            }
            if (title.contains("荒泷一斗")) {
                wuxingarr.append("21,");
            }
            if (title.contains("申鹤")) {
                wuxingarr.append("22,");
            }
            if (title.contains("八重神子")) {
                wuxingarr.append("23,");
            }

            if (StringUtils.isNotEmpty(wuxingarr)) {
                String substring = wuxingarr.toString().substring(0, wuxingarr.toString().length()-1);
                params.put("wuxingarr", substring);
            }


            StringBuffer sixingarr = new StringBuffer();
            if (title.contains("迪奥娜")) {
                sixingarr.append("1,");
            }
            if (title.contains("砂糖")) {
                sixingarr.append("2,");
            }
            if (title.contains("重云")) {
                sixingarr.append("3,");
            }
            if (title.contains("诺艾尔")) {
                sixingarr.append("4,");
            }
            if (title.contains("班尼特")) {
                sixingarr.append("5,");
            }
            if (title.contains("凝光")) {
                sixingarr.append("6,");
            }
            if (title.contains("行秋")) {
                sixingarr.append("7,");
            }
            if (title.contains("北斗")) {
                sixingarr.append("8,");
            }
            if (title.contains("香菱")) {
                sixingarr.append("9,");
            }
            if (title.contains("雷泽")) {
                sixingarr.append("10,");
            }
            if (title.contains("芭芭拉")) {
                sixingarr.append("11,");
            }
            if (title.contains("菲谢尔")) {
                sixingarr.append("12,");
            }
            if (title.contains("辛焱")) {
                sixingarr.append("13,");
            }
            if (title.contains("安柏")) {
                sixingarr.append("14,");
            }
            if (title.contains("丽莎")) {
                sixingarr.append("15,");
            }
            if (title.contains("凯亚")) {
                sixingarr.append("16,");
            }
            if (title.contains("罗莎莉亚")) {
                sixingarr.append("17,");
            }
            if (title.contains("烟绯")) {
                sixingarr.append("18,");
            }
            if (title.contains("早柚")) {
                sixingarr.append("19");
            }
            if (title.contains("九条裟罗")) {
                sixingarr.append("20,");
            }
            if (title.contains("托马")) {
                sixingarr.append("21,");
            }
            if (title.contains("五郎")) {
                sixingarr.append("22,");
            }
            if (title.contains("云堇")) {
                sixingarr.append("23,");
            }

            if (StringUtils.isNotEmpty(sixingarr)) {
                String substring = sixingarr.toString().substring(0, sixingarr.toString().length()-1);
                params.put("sixingarr", substring);
            }

            StringBuffer wuxingwuqiarr = new StringBuffer();

            if (title.contains("终末嗟叹之诗")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("天空之卷")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("风鹰剑")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("四风原典")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("阿莫斯之弓")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("天空之傲")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("狼的末路")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("和璞鸢")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("天空之翼")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("天空之脊")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("天空之刃")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("尘世之锁")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("贯虹之槊")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("无工之剑")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("斫峰之刃")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("护摩之杖")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("磐岩结绿")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("松籁响起之时")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("苍古自由之誓")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("雾切之回光")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("飞雷之弦振")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("薙草之稻光")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("不灭月华")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("冬极白星")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("赤角石溃杵")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("息灾")) {
                wuxingwuqiarr.append("23,");
            }
            if (title.contains("神乐之真意")) {
                wuxingwuqiarr.append("23,");
            }

            if (StringUtils.isNotEmpty(wuxingwuqiarr)) {
                String substring = wuxingwuqiarr.toString().substring(0, wuxingwuqiarr.toString().length()-1);
                params.put("wuxingwuqiarr", substring);
            }
            params.put("product_id", accountInfo.getId().toString());
        }
        return params;
    }


    private String regionalCover(String game, String regional) {
        if (game.equals(GameTypeConstant.WZRY)) {
            if (Objects.equals("安卓Q", regional)) {
                return "7";
            } else if (Objects.equals("安卓WX", regional)) {
                return "9";
            } else if (Objects.equals("苹果WX", regional)) {
                return "8";
            } else if (Objects.equals("苹果Q", regional)) {
                return "6";
            } else {
                return null;
            }
        } else if (game.equals(GameTypeConstant.HPJY)) {
            if (Objects.equals("安卓Q", regional)) {
                return "11";
            } else if (Objects.equals("安卓WX", regional)) {
                return "13";
            } else if (Objects.equals("苹果WX", regional)) {
                return "12";
            } else if (Objects.equals("苹果Q", regional)) {
                return "10";
            } else {
                return null;
            }
        } else if (game.equals(GameTypeConstant.YS)) {
            return "4";
        }
        return null;
    }

}
